<?php
$smarty->configLoad($lang . '/myprofile.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['mail'];
if(empty($_GET['userID'])) {
	$userID = $_SESSION['id'];
} else {
	$userID = $_GET['userID'];
}
$sql = 'SELECT m.mailUniqueId, m.mailRecipientId, m.senderName, m.mailTitle, p.name, p.account_id, p.account_name FROM '.DB_GAME.'.mail AS m LEFT JOIN '.DB_GAME.'.players AS p ON p.id = m.mailRecipientId WHERE account_id = :userID';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':userID', $userID);
$dbh->execute();
$value = '';
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
	$value[] = $row;
}
$smarty->assign('value', $value);
$smarty->assign('userID', $userID);
$template = 'profile/mails.tpl';
?>
